
package py.una.pol.raphapy.autoventas.model;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Rafael E. Benegas
 */
@Entity
@Table(name = "vendedor")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Vendedor.findAll", query = "SELECT v FROM Vendedor v"),
    @NamedQuery(name = "Vendedor.findByCodVen", query = "SELECT v FROM Vendedor v WHERE v.codVen = :codVen"),
    @NamedQuery(name = "Vendedor.findByFecAlta", query = "SELECT v FROM Vendedor v WHERE v.fecAlta = :fecAlta"),
    @NamedQuery(name = "Vendedor.findByFecBaja", query = "SELECT v FROM Vendedor v WHERE v.fecBaja = :fecBaja")})
public class Vendedor implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "cod_ven")
    private Long codVen;
    @Basic(optional = false)
    @NotNull
    @Column(name = "fec_alta")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fecAlta;
    @Column(name = "fec_baja")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fecBaja;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "vendedor")
    private Collection<PuntoPreventa> puntoPreventaCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "codVen")
    private Collection<VentaMercaderia> ventaMercaderiaCollection;
    @JoinColumn(name = "cod_ven", referencedColumnName = "cod_per", insertable = false, updatable = false)
    @OneToOne(optional = false)
    private Persona persona;

    public Vendedor() {
    }

    public Vendedor(Long codVen) {
        this.codVen = codVen;
    }

    public Vendedor(Long codVen, Date fecAlta) {
        this.codVen = codVen;
        this.fecAlta = fecAlta;
    }

    public Long getCodVen() {
        return codVen;
    }

    public void setCodVen(Long codVen) {
        this.codVen = codVen;
    }

    public Date getFecAlta() {
        return fecAlta;
    }

    public void setFecAlta(Date fecAlta) {
        this.fecAlta = fecAlta;
    }

    public Date getFecBaja() {
        return fecBaja;
    }

    public void setFecBaja(Date fecBaja) {
        this.fecBaja = fecBaja;
    }

    @XmlTransient
    public Collection<PuntoPreventa> getPuntoPreventaCollection() {
        return puntoPreventaCollection;
    }

    public void setPuntoPreventaCollection(Collection<PuntoPreventa> puntoPreventaCollection) {
        this.puntoPreventaCollection = puntoPreventaCollection;
    }

    @XmlTransient
    public Collection<VentaMercaderia> getVentaMercaderiaCollection() {
        return ventaMercaderiaCollection;
    }

    public void setVentaMercaderiaCollection(Collection<VentaMercaderia> ventaMercaderiaCollection) {
        this.ventaMercaderiaCollection = ventaMercaderiaCollection;
    }

    public Persona getPersona() {
        return persona;
    }

    public void setPersona(Persona persona) {
        this.persona = persona;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (codVen != null ? codVen.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        
        if (!(object instanceof Vendedor)) {
            return false;
        }
        Vendedor other = (Vendedor) object;
        if ((this.codVen == null && other.codVen != null) || (this.codVen != null && !this.codVen.equals(other.codVen))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "py.una.pol.raphapy.autoventas.model.Vendedor[ codVen=" + codVen + " ]";
    }
    
}
